package com.zking.frame;

import com.zking.utils.Tool工具;

import javax.swing.*;
import javax.swing.border.MatteBorder;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;

/*展示商品*/
public class Commodity {

	private JPanel jPanel,jPanel2;// 面板
	private JLabel jlable;// 文本标签

	public Commodity(JFrame a, String sort, String shop) {

		a.dispose();
		JFrame jFrame = Tool工具.getJFrame();

		// 设置背景
		ImageIcon icon = new ImageIcon(HomePage.class.getResource("jf.jpg"));
		JLabel jLabel1 = new JLabel(icon);
		jLabel1.setBounds(0, 0, 645, 900);
		jFrame.add(jLabel1, -1);

		//设置面板
		jPanel2 = new JPanel();
		jPanel2.setBounds(10,40,615,900);
		jPanel2.setLayout(null);
		jFrame.add(jPanel2,0);

		jlable = new JLabel("返回商铺", 0);
		jlable.setFont(new Font("黑体", Font.BOLD, 20));
		jlable.setBounds(10, 10, 100, 30);
		jlable.setCursor(new Cursor(Cursor.HAND_CURSOR));
		jlable.setBorder(new MatteBorder(2, 2, 2, 2, new Color(254, 253, 129)));
		// 设置点击事件
		jlable.addMouseListener(new MouseAdapter() {
			public void mouseClicked(MouseEvent e) {
				if (e.getClickCount() == 1) {
					new SweetMilkTea(jFrame,sort);
				}
			}
		});
		jFrame.add(jlable, 0);

		//调用商品显示的方法
		jPanel = Tool工具.getjpFoods(sort,shop,jFrame);
		jPanel2.add(jPanel);

		// 加载并刷新面板
		jFrame.repaint();
		jFrame.revalidate();

	}

}

